package Lambda_BilibilI;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class StreamDemo {

    public static void main(String[] args) {
        List<Author> authors = getAuthors();

//        for (Author author : authors){
//            System.out.println(author);
//        }

//        authors.stream()
//                .distinct()
//                .filter(n -> n.getAge() >= 15)
//                .forEach(n -> System.out.println(n));

        authors.stream()
                .filter(n -> n.getName().length() > 1)
                .forEach(n -> System.out.println(n.getName()));
    }

    private static List<Author> getAuthors(){

        Author author1 = new Author(1L,"蒙多",33,"一个从",null);
        Author author2 = new Author(2L,"亚拉索",15,"狂风也追逐",null);
        Author author3 = new Author(3L,"易",14,"是这个世界在限制他的思维",null);
        Author author4 = new Author(4L,"易",14,"是这个世界在限制他的思维",null);

        List<Book> books1 = new ArrayList<>();
        List<Book> books2 = new ArrayList<>();
        List<Book> books3 = new ArrayList<>();

        books1.add(new Book(1L,"刀的两侧","哲学,爱情",88,"用一把刀"));
        books1.add(new Book(2L,"一个人","个人成长,爱情",99,"讲述如何"));

        books2.add(new Book(3L,"那风吹不到的地方","哲学",85,"带你用思维去"));
        books2.add(new Book(3L,"那风吹不到的地方","哲学",85,"带你用思维去"));
        books2.add(new Book(4L,"吹或不吹","个人传记",56,"一个哲学家"));

        books3.add(new Book(5L,"你的剑","爱情",56,"无法想象"));
        books3.add(new Book(6L,"风与剑","个人传记",100,"两个哲学家"));
        books3.add(new Book(6L,"风与剑","个人传记",100,"两个哲学家"));

        author1.setBooks(books1);
        author2.setBooks(books2);
        author3.setBooks(books3);
        author4.setBooks(books3);


        List<Author> authorList = new ArrayList<>(Arrays.asList(author1,author2,author3,author4));
        return authorList;
    }
}
